// 6.43 编写递归算法，将二叉树中所有结点的左、右子树相互交换。
#include <stdio.h>
#include <stdlib.h>
#include "E:\Desktop\data_struct\5TREE\1_bin_tree\creat.h"

void fun_6_43(tree *root)
{
    if (root)
    {
        tree *l, *r;
        l = root->left;
        r = root->right;
        root->left = r;
        root->right = l;
        fun_6_43(root->left);
        fun_6_43(root->right);
    }
}

int main()
{
    /*******************code*******************/
    int n = 15;
    int a1[15] = {1,
                  2, 3,
                  4, 5, NULL, NULL,
                  NULL, 6, 7, NULL, NULL, NULL, NULL, NULL};
    tree *root;
    CreatTree(root, a1, n, 0);
    fun_6_43(root);
    /******************************************/
    printf("\n\n****************************\n");
    printf("Press Enter key to continue\n");
    getchar();
    return 0;
    /******************************************/
}
